<template>
  <Dialog :title="dialogTitle" v-model="dialogVisible" :width="'70%'">
    <!-- 列表 -->
      <ContentWrap>
        <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
          <!-- <el-table-column label="编号" align="center" prop="id" /> -->
          <!-- <el-table-column label="物资ID" align="center" prop="assetId" /> -->
          <el-table-column label="物资名称" align="center" prop="assetName" />
          <el-table-column label="物资编号" align="center" prop="assetCode" />
          <!-- <el-table-column label="数量" align="center" prop="count" /> -->
           <el-table-column label="状态" align="center" prop="status">
            <template #default="scope">
              <dict-tag :type="DICT_TYPE.SCHOOL_ASSET_OPER_STATUS" :value="scope.row.status" />
            </template>
          </el-table-column>
          <el-table-column label="领用人" align="center" prop="userNames" />
          <el-table-column label="维修费用（元）" align="center" prop="price" />
          <el-table-column label="备注" align="center" prop="remark" />
          <el-table-column
            label="创建时间"
            align="center"
            prop="createTime"
            :formatter="dateFormatter"
            width="180px"
          />
         

        </el-table>
        <!-- 分页 -->
        <Pagination
          :total="total"
          v-model:page="queryParams.pageNo"
          v-model:limit="queryParams.pageSize"
          @pagination="getList"
        />
      </ContentWrap>

  </Dialog>

 

</template>
<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import { DICT_TYPE } from '@/utils/dict'
import { AssetsFlowApi, AssetsFlowVO } from '@/api/school/assets/flow'

/** 固定资产 表单 */
defineOptions({ name: 'AssetsFixedForm' })


const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // 弹窗的标题
const formLoading = ref(false) // 表单的加载中：1）修改时的数据加载；2）提交的按钮禁用

const loading = ref(true) // 列表的加载中
const list = ref<AssetsFlowVO[]>([]) // 列表的数据
const total = ref(0) // 列表的总页数
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  categoryId: undefined,
  assetType: 0,
  assetId: 0,
  assetCode: undefined,
  assetName: undefined,
  status: undefined,
  userNames: undefined,
  createTime: [],
  oper: 'all',
})


/** 打开弹窗 */
const open = async ( assetId: number) => {
  dialogVisible.value = true
  dialogTitle.value =  '物资流转记录'
  // 设置数据
  formLoading.value = true
  try {
    queryParams.assetId = assetId
    getList()
  } finally {
    formLoading.value = false
  }

}

/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    const data = await AssetsFlowApi.getAssetsFlowPage(queryParams)
    list.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}

defineExpose({ open }) // 提供 open 方法，用于打开弹窗

</script>

